package com.boot.controller;


import com.boot.entity.Admin;
import com.boot.entity.R;
import com.boot.service.AdminService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 管理员表(Admin)表控制层
 *
 * @author makejava
 * @since 2023-07-20 18:48:24
 */
@RestController
@RequestMapping("/admin")
@CrossOrigin
public class AdminController {
    /**
     * 服务对象
     */
    @Autowired
    private AdminService adminService;

    @RequestMapping("/login")
    public R login(Admin am){
        System.out.println(am);
        Admin admin = adminService.selectByName(am.getName(),am.getPassword());
        /*HttpServletRequest.getSession().setAttribute("admin",admin);*/
        admin.setPassword(null);

        return R.success(admin);
    }


}

